﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BSCMFF.Core.DataAccessLayer;
using Telerik.Web.UI;

namespace BSCMFF.Web.UserControls.Details
{
    public partial class DetailsKPI : System.Web.UI.UserControl
    {
        private KPI _kpi = new KPI();

        public KPI KPI 
        {
            get
            {
                if (_kpi.Name == null)
                {
                    int tempID = 0;
                    Int32.TryParse(LabelKPIID.Text, out tempID);
                    _kpi.KPI_ID = tempID;
                    _kpi.Name = TextBoxName.Text;
                    _kpi.Description = TextBoxDescription.Text;
                }
                return _kpi;
            }
            set
            {
                _kpi = value;
            }
        }

        public bool ShowButtons 
        {
            get
            {
                return TableButtons.Visible == true;
            }
            set
            {
                TableButtons.Visible = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            //BSCEntities context = new BSCEntities();

            //KPI = (from kpi in context.KPIs
            //            where kpi.KPI_ID == 1
            //            select kpi).SingleOrDefault();

            //this.DataBind();
        }

        public void DisableTextBoxes()
        {
            foreach(Control c in this.Controls)
            {
                if(c.GetType() == typeof(RadTextBox))//|| c.GetType() == typeof(RadNumericTextBox))
                {
                   ((RadTextBox)c).Enabled = false;
                   ((RadTextBox)c).EmptyMessage = "";
                }
                if(c.GetType() == typeof(RadNumericTextBox))
                {
                   ((RadNumericTextBox)c).Enabled = false;
                    ((RadNumericTextBox)c).EmptyMessage = "";
                }
            }

        }
    }
}